<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="com.duleme.entity.UserInfo" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人信息设置</title>
    <link rel="stylesheet" href="/style/First_Page.css"/>
    <script type="text/javascript" src="js/First_Page.js"></script>
    <link rel="stylesheet" href="/style/Self_Information.css"/>
    <script type="text/javascript" src="/js/Self_Information.js"></script>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
        window.onload=function () {
            var a ="${sessionScope.login}";
            if(a=="1"){
                document.getElementById("login").style.display="none";
                document.getElementById("avatar").style.display="inline";
                document.getElementById("buy_car").style.display="inline";
                document.getElementById("car_image").style.display="inline";
                document.getElementById("exit").style.display="inline";

            }
            else{
                document.getElementById("login").style.display="inline";
                document.getElementById("avatar").style.display="none";
                document.getElementById("buy_car").style.display="none";
                document.getElementById("car_image").style.display="none";
                document.getElementById("exit").style.display="none";

            }
        }
    </script>
</head>
<body>

<% SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");%>
<% String date = format.format(((UserInfo)session.getAttribute("userInfo")).getBirthday());%>
<div id="main_head_box">
    <div class="head_box">
        <div id="head_wrap">
            <div id="head_right">
                <div id="head_landing">
                    <a id="login" class="head_nav_a" href="Login.html" style="display: inline;">登陆/注册</a>
                    <a href="Self_Information.jsp"><img src="${sessionScope.user.avatar}" id="avatar" style="display: none;height:30px;width:30px;border-radius: 45px;margin-right:50px;margin-top: 5px;"></a>
                    <a id="exit" style="display: none;float:right;margin-left:15px;" href="First_Page.jsp" onclick="login2exit()">注销</a>
                    <img src="image/buy_car.jpg" style="display:none;height:30px;width:30px;border-radius: 90px" id="car_image">
                    <a id="buy_car" class="head_nav_a" style="display: block;float:right;margin-left:5px;" href="Buy_Car.jsp">购物车</a>
                </div>
            </div>
        </div>
    </div>
    <div id="menu_wrap">
        <p id="menu_logo">读了么 <i>DuLeMe.com</i></p>
        <div id="find_wrap">
            <div id="find_bar">
                <input type="text" id="find_input">
            </div>
            <div id="find_but" onclick="search_method()"><a>GO</a></div>
        </div>
    </div>
</div>
<div class="self_main">
    <p class="self_title"><b>个人信息设置</b></p>
    <div class="self_body">
        <div class="self_body_portrait">
            <img src=${sessionScope.user.avatar} id="head_portrait" alt="Base64 encoded image" onclick="file_upload()">
            <p id="pet_name"><b>${sessionScope.user.userName}</b></p>
        </div>
        <div class="update_portrait">
            <form enctype="multipart/form-data" action="http://localhost:8080/uploadAvatar" method="post">
                <input type="file" value="点此上传头像" id="upload" name="upload" accept="image/jpeg,image/gif">
                <p>点击图片上传</p>
                <input type="submit" value="立刻上传" id="bookUpper" style="display: none;border: none;color:red;background: #fafafa;margin:10px">
            </form>
        </div>
        <p id="self_createDate"><b>创建日期 : 2019 . 6 . 30</b></p>
        <div class="self_body_information">
            <p class="information_title"><b>姓名：</b></p><p id="self_name"><b>${sessionScope.userInfo.name}</b></p>
        </div>
        <div class="self_body_information">
            <p class="information_title"><b>出生日期：</b></p><p id="self_birth"><b id="birthday_id"><%=date%></b></p>
            <input type="button" id="change_birth" value="修改生日" onclick="changeBirth()">
            <input type="button" id="change_birth_return" value="返回" onclick="changeBirth_return()">
            <form name="reg_testdate" class="birth_update" id="birth_change">
                <select name="YYYY" id="year" onchange="YYYYDD(this.value)">
                    <option value="">请选择 年</option>
                </select>
                <select name="MM" id="month" onchange="MMDD(this.value)">
                    <option value="">选择 月</option>
                </select>
                <select name="DD" id="day">
                    <option value="">选择 日</option>
                </select>
            </form>
        </div>
        <div class="self_body_information">
            <p class="information_title"><b>性别：</b></p><p id="self_sex"></p>
            <input type="button" id="change_sex" value="修改性别" onclick="changeSex()">
            <input type="button" id="change_sex_return" value="返回" onclick="changeSex_return()">
            <div id="sex_div" style="display: none;">
                <input type="radio" id="man" name="sex" value="1" checked="checked"><p style="margin-left: 1020px;float:left;margin-top: -35px;">男</p>
                <input type="radio" id="woman" name="sex" value="2"><p style="margin-left: 1070px;float:left;margin-top: -35px;">女</p>
            </div>
        </div>
        <div class="self_body_information">
            <p class="information_title"><b>手机号：</b></p><p id="self_phoneNum"><b>${sessionScope.userInfo.phoneNumber}</b></p>
            <input type="text" placeholder="请输入11位手机号" id="phone_input">
            <input type="button" id="change_phone" value="修改手机号" onclick="changePhone()">
            <input type="button" id="change_phone_return" value="返回" onclick="changePhone_return()">
        </div>
        <div class="self_body_information">
            <p class="information_title"><b>邮箱：</b></p><p id="self_email"><b>${sessionScope.userInfo.emailAddress}</b></p>
            <input type="text" placeholder="请输入邮箱(10~20字符)" id="email_input">
            <input type="button" id="change_email" value="修改邮箱号" onclick="changeEmail()">
            <input type="button" id="change_email_return" value="返回" onclick="changeEmail_return()">
        </div>
        <div class="self_body_information">
            <p class="information_title"><b>身份证号：</b></p><p id="self_Id"><b id="cer_id"></b></p>
        </div>
        <div class="self_body_information">
            <input type="button" id="change_password" value="修改密码" onclick="change_password()">
            <input type="button" id="Real_name_authentication" value="实名认证" onclick="Real_authentication()">
        </div>
        <div id="Real_name_authentication_div">
            <div class="self_body_information">
                <p><b>姓名：</b></p>
                <input type="text" placeholder="请输入姓名" id="name_authentication">
            </div>
            <div class="self_body_information">
                <p><b>性别：</b></p>
                <div id="sex_authentication_div">
                    <input type="text" placeholder="请输入性别" id="sex_authentication" value="男">
                </div>
            </div>
            <div class="self_body_information">
                <p><b>身份证号：</b></p>
                <input type="text" placeholder="请输入身份证号" id="id_authentication">
            </div>
            <div class="self_body_information">
                <input type="button" value="提交" id="submit_button" onclick="submit_data()">
            </div>
        </div>
    </div>
</div>
<div id="foot_box">
    <div id="foot_wrap">
        <div class="foot_top">
            <ul>
                <li><a href="Self_Information.jsp">个人信息设置</a></li>
                <li class="font_top_i">|</li>
                <li><a href="Bookshop.html">热门店家推荐</a></li>
                <li class="font_top_i">|</li>
                <li><a href="First_Page.jsp">返回首页</a></li>
                <li class="font_top_i">|</li>
                <li>用户购物指南</li>
                <li class="font_top_i">|</li>
                <li><a href="user_Agreement.html">用户协议须知</a></li>
            </ul>
        </div>
        <div class="foot_bottom">
            <span> <a href="">返回顶部</a></span>
        </div>
    </div>
</div>
</body>
<script>
    var sex = "${sessionScope.userInfo.sex}";
    var cer = "${sessionScope.userInfo.id}";
    if (sex=="1"){
        document.getElementById("self_sex").innerText="男";
    }else {
        document.getElementById("self_sex").innerText="女";
    }

    var c1 = cer.substr(0,3);
    var c2 = cer.substr(cer.length-3,3);
    var c = c1+"**********"+c2;
    $("#cer_id").text(c);

    $(window).load(function () {

    });

</script>>
</html>